<?php

namespace App\Http\Transformers;

use League\Fractal\TransformerAbstract;
use App\Models\Permissions;

class CurrentPermissionTransformer extends TransformerAbstract
{
    public function transform(Permissions $permissions )
    {
        $data = $permissions->toArray();

        $arrData = [];
        foreach ($data as $datum){
            if($datum['type'] == TYPE_MENU){
                $arrData['menu'][] = $datum;
            } else {
                $arrData['action'][] = $datum;
            }
        }

        return $arrData;
    }
}